import type { IPageData } from "~/types/common";
import type { IChannelRevenue } from "~/types/manage/channel/coin";
import type { IChannel, IChannelTag } from "~/types/manage/channel/list";
import { request } from "~/utils/http";

export const apiAddChannel = (data: Partial<IChannel>) =>
  request.post("/channels", data);

export const apiModifyChannel = (id: number, data: Partial<IChannel>) =>
  request.put(`/channels/${id}`, data);

export const apiChannelAll = (): Promise<IChannel[]> =>
  request.get("/channels/all");

export const apiChannelList = (params?: {
  name?: string;
  companyName?: string;
}): Promise<IPageData<IChannel>> =>
  request.get("/channels/list", {
    params,
  });

export const apiChannelMonthlyRevenue = (params: {
  year: string;
  name: string;
}) =>
  request.get(`/channels/monthly/revenue`, {
    params,
  });

export const apiAddChannelRevenue = (data: Partial<IChannelRevenue>) =>
  request.post(`/channels/monthly/revenue`, data);

export const apiModifyChannelRevenue = (
  id: number,
  data: Partial<IChannelRevenue>,
) => request.put(`/channels/monthly/revenue/${id}`, data);

export const apiAddChannelTag = (data: Partial<IChannelTag>) =>
  request.post(`/channels/tags`, data);

export const apiChannelTagTree = (channelId: number) =>
  request.get(`/channels/${channelId}/tags/tree`);

export const apiChannelTagsAll = () => request.get(`/channels/tags/all`);
